using System;
using System.Collections.Generic;
using System.Text;

namespace SymAutomate.Util
{
    /// <summary>
    /// Error Numbers 600-619; Reference file ErrorNumbers.txt for more information.
    /// 
    /// 600 Error: Required argument 'encryptkey' missing. Use /h switch for help.
    /// 601 Error: Required argument 'encryptvalue' missing. Use /h switch for help.
    /// 602 Error: 'encryptkey' is invalid.
    /// </summary>
    class Parameters : ParametersBase
    {
        #region Class Variables and Access Methods
        private string __DateFormat;

        private string __EncryptKey;
        private string __EncryptValue;

        public string DateFormat { get { return __DateFormat; } }

        public string EncryptKey { get { return __EncryptKey; } }
        public string EncryptValue { get { return __EncryptValue; } }
        #endregion

        public Parameters(ConsoleArguments _ConsoleArguments, List<ConsoleHelp> _ConsoleHelpList)
            : base(_ConsoleArguments, _ConsoleHelpList)
        {
            //defaults
            __EncryptKey = string.Empty;
            __EncryptValue = string.Empty;

            //read from config file

            //save from command line arguments
            if (_ConsoleArguments.ArgumentCollection.Contains("dateformat")) __DateFormat = _ConsoleArguments.ArgumentCollection["dateformat"].ToString();
            if (_ConsoleArguments.ArgumentCollection.Contains("encryptkey")) __EncryptKey = _ConsoleArguments.ArgumentCollection["encryptkey"].ToString();
            if (_ConsoleArguments.ArgumentCollection.Contains("encryptvalue")) __EncryptValue = _ConsoleArguments.ArgumentCollection["encryptvalue"].ToString();


            //perform argument error checking
            if (_ConsoleArguments.ArgumentCollection["command"].ToString().ToLower() == "SetEncryptedValue".ToLower())
            {
                if (string.IsNullOrEmpty(__EncryptKey))
                    throw new ReturnException("600 Error: Required argument 'encryptkey' missing. Use /h switch for help.");

                if (string.IsNullOrEmpty(__EncryptValue))
                    throw new ReturnException("601 Error: Required argument 'encryptvalue' missing. Use /h switch for help.");

                if (__EncryptKey != "aixpassword" && __EncryptKey != "symopoperatorid" && __EncryptKey != "symuserid" && __EncryptKey != "ftpserverpassword")
                    throw new ReturnException("602 Error: 'encryptkey' is invalid.");
            }
        }
    }
}
